var express = require('express');
var router = express.Router();
var http = require('http');
const https = require('https')
var cheerio = require('cheerio');
var loggerInfo = require('../utils/winston-date').logger;// 自定义打印 包含日志文件分割功能
var loggerError = require('../utils/winston-date').loggerError;// 自定义打印 包含日志文件分割功能
var iconv = require('iconv-lite');
let query = require('../utils/db2');//打开数据库连接
let db = require('../utils/db');//打开数据库连接
let connection = db.connection();//打开数据库连接
var hcsy = require('../utils/hcsy-date');//引用自己的文件
let appConfig = require('../utils/app-config');//基础配置
var request = require('request');// 请求 第三方Api
var UpdateDataNum = 0;// 更新数据的次数
var schedule = require('node-schedule');//定时器依赖
let basic = require("../utils/basic.js");

let ajax = require("../utils/ajax");// 同步请求

//优惠券登录获取验证码
router.post("/sms", function (req, res, next) {
    var e = request({
        url: "http://ccb.e-mallchina.com.cn/login",
        method: 'post',
        headers: { 'Content-Type': 'application/json;charset=UTF-8' }
    }, function (error, response, body) {
        if (!error && response.statusCode == 200) {

         }
    })
})

//优惠券登录
router.post("/login", function (req, res, next) {
    var e = request({
        url: "http://ccb.e-mallchina.com.cn/login",
        method: 'post',
        headers: { 'Content-Type': 'application/json;charset=UTF-8' }
    }, function (error, response, body) {
        if (!error && response.statusCode == 200) {

         }
    })
})


$.ajax({
    url: "http://ccb.e-mallchina.com.cn/shop/order-pay",
    type: "POST",
    contentType: "application/json;charset=UTF-8",//application/json：application/x-www-form-urlencoded
    data: JSON.stringify({
        expired:"1025",
        token: "70480b9b5f42f90f202dd5d7ac56ae68f1e38dbd",
        sn: "JH2018122249936149",// 创建订单之后获取到的
		mobile:"15757101751",
		verifyCode:"2451"
    }), success: function (re) {
        console.log(re);
    },
    beforeSend: function (xhr) {
        xhr.setRequestHeader("Accept", "application/json, text/plain, */*");
        xhr.setRequestHeader("X-XSRF-TOKEN", "eyJpdiI6IlpuUlNGM3dpdEZTeEJROGJTQ2FOTlE9PSIsInZhbHVlIjoiYWd2M05KUUZwTVVwbDBXemtSb2JjVXRmSGNjSlNHc25tWDJweXZvcWtzYmxwc3l0WHZRMk1FTk9tVU8zUWo0dW40Uldhd3N1cDBBSTRYd1Y4cnVtMGc9PSIsIm1hYyI6IjQxYzBhZDlmN2JjYzVkYzZmNmFiZjFjMTkwZDczMGZlMDE4ZDIxNTk0ZTRjYThmZTQ1ZTYxYzllMWY2OWM2YWQifQ==");
    }
});

$.ajax({
    url: "http://ccb.e-mallchina.com.cn/shop/order-detail",
    type: "POST",
    contentType: "application/json;charset=UTF-8",//application/json：application/x-www-form-urlencoded
    data: JSON.stringify({
        token: "70480b9b5f42f90f202dd5d7ac56ae68f1e38dbd",
        sn: "JH2018122249936149",// 创建订单之后获取到的
    }), success: function (re) {
        console.log(re);
    },
    beforeSend: function (xhr) {
        xhr.setRequestHeader("Accept", "application/json, text/plain, */*");
        xhr.setRequestHeader("X-XSRF-TOKEN", "eyJpdiI6IlpuUlNGM3dpdEZTeEJROGJTQ2FOTlE9PSIsInZhbHVlIjoiYWd2M05KUUZwTVVwbDBXemtSb2JjVXRmSGNjSlNHc25tWDJweXZvcWtzYmxwc3l0WHZRMk1FTk9tVU8zUWo0dW40Uldhd3N1cDBBSTRYd1Y4cnVtMGc9PSIsIm1hYyI6IjQxYzBhZDlmN2JjYzVkYzZmNmFiZjFjMTkwZDczMGZlMDE4ZDIxNTk0ZTRjYThmZTQ1ZTYxYzllMWY2OWM2YWQifQ==");
    }
})

$.ajax({
    url: "http://ccb.e-mallchina.com.cn/shop/send-sms",
    type: "POST",
    contentType: "application/json;charset=UTF-8",//application/json：application/x-www-form-urlencoded
    data: JSON.stringify({
        token: "70480b9b5f42f90f202dd5d7ac56ae68f1e38dbd",
        sn: "JH2018122249936149",// 创建订单之后获取到的
		mobile:"15757101751" 
    }), success: function (re) {
        console.log(re);
    },
    beforeSend: function (xhr) {
        xhr.setRequestHeader("Accept", "application/json, text/plain, */*");
        xhr.setRequestHeader("X-XSRF-TOKEN", "eyJpdiI6IlpuUlNGM3dpdEZTeEJROGJTQ2FOTlE9PSIsInZhbHVlIjoiYWd2M05KUUZwTVVwbDBXemtSb2JjVXRmSGNjSlNHc25tWDJweXZvcWtzYmxwc3l0WHZRMk1FTk9tVU8zUWo0dW40Uldhd3N1cDBBSTRYd1Y4cnVtMGc9PSIsIm1hYyI6IjQxYzBhZDlmN2JjYzVkYzZmNmFiZjFjMTkwZDczMGZlMDE4ZDIxNTk0ZTRjYThmZTQ1ZTYxYzllMWY2OWM2YWQifQ==");
    }
});

module.exports = router;